/*Copyright (C) 2009 - 2011 MASSART GAUTHIER

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TETRIS_HEADER
# define TETRIS_HEADER

#define TET_VIDE 0
#define TET_FANTOME 1
#define TET_HACHURE 8
#define TET_LARGEUR 10
#define TET_HAUTEUR 30
#define TET_TOURNER 5
#define TET_SIGNE_GAUCHE '['
#define TET_SIGNE_DROITE ']'
#define TET_POS_MAT_X x_begin_center(19)
#define TET_POS_MAT_Y 7
#define TET_POS_PROCH_X DEFAULT_SCREEN_SIZE_X/2 + 18
#define TET_POS_PROCH_Y 9
#define TET_POS_RES_X x_begin_center(43)
#define TET_POS_RES_Y 13
#define TET_NO_EVENT 111
#define TET_QUITTER 101
#define TET_ATTENTE_ANIM 50
#define TET_NB_LIGNES_DEBUT 5
#define TET_RESERVE 70
#define TET_BLOCK_FANTOME "▒"


typedef struct {
	Position posP[4];
	int couleur;
	int blocTourne;
	int type;
} forme;

void tet_menu(void);
void tet_man(void);
void tet_jeu(void);
void tet_init(forme pieces[]);
void tet_affiche_legende();
void tet_tourner_forme(forme *aTourner);
void tet_tourner(int matrice[][TET_HAUTEUR], forme *piece);
int tet_bouger(int matrice[][TET_HAUTEUR], int comment, forme *laPiece);
void tet_animation_enlever_ligne(int matrice[][TET_HAUTEUR], int lignesPleines[]);
void tet_enlever_ligne(int matrice[][TET_HAUTEUR], int y);
void rajouter_ligne(int matrice[][TET_HAUTEUR]);
void tet_afficher(int matrice[][TET_HAUTEUR]);
void afficher_bloc(int y, int x, int couleur);
int recup_event(void);
int nouvelle_piece(int matrice[][TET_HAUTEUR], forme pieces[], forme *ancienne, forme *nouvelle, forme *theReserve);
int descendre_piece(int matrice[][TET_HAUTEUR], forme *piece);
void verif_ligne_pleine(int matrice[][TET_HAUTEUR], int lignesPleines[]);
void afficher_cadre_tetris();
void animation_perdu(int matrice[][TET_HAUTEUR]);
void s_occuper_reserve(forme *laReserve);
void afficher_fantome(int matrice[][TET_HAUTEUR], forme pActuelle);

extern int tetris_lignes, tetris_points, tetris_niveau, tetris_nombre_lignes_debut, tetris_premier_appel, tetris_ancien_niveau, tetris_meilleur_score;
#endif
